package com.hujf.mapreduce.paeritionAndWritableCompare;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * @author Hujf
 * @title: FlowReducer
 * @date 2021/3/3017:29
 * @description: TODO
 */
public class FlowReducer extends Reducer<FlowBean,Text ,Text, FlowBean> {

    private FlowBean bean = new FlowBean();

    @Override
    protected void reduce(FlowBean key, Iterable<Text> values, Context context) throws IOException, InterruptedException {
        for(Text t:values){
            context.write(t,key);
        }

    }
    //    @Override
//    protected void reduce(Text key, Iterable<FlowBean> values, Context context) throws IOException, InterruptedException {
//        long uplong = 0;
//        long downlong =0;
//        //遍历
//        for (FlowBean value : values) {
//            uplong+=value.getUpFlow();
//            downlong+=value.getDownFlow();
//        }
//        bean.setUpFlow(uplong);
//        bean.setDownFlow(downlong);
//        bean.setTotal();
//        context.write(key,bean);
//    }
}
